﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace MemoryScannerTestConsoleApp {
    class Program {
        static void Main(string[] args) {
            Console.Out.WriteLine( "test0" );
            if ( args[0] == null ) {
                Console.Out.WriteLine("No process name specified");
                
                return;
            }

            
            ActiveProcessConnection processConnection;
            
            try {
                processConnection = new ActiveProcessConnection( args[0] );
                using ( processConnection ) {
                    //processConnection.RelativeAddress = true;
                    processConnection.DataAlignment = ProcessInterop.DataAlignment.Byte4;

                    byte[] b = processConnection.ReadBytes( 68000, 64 );
                    //byte b1 = processConnection.ReadByte( 0 );
                    //float pass = processConnection.ReadFloat( 0 );

                    byte[] b2 = processConnection.ReadBytes( 198156, 4 );
                    byte[] b3 = processConnection.ReadBytes( 204436, 4 );
                    byte[] b4 = processConnection.ReadBytes( 213258, 4 );

                    IntPtr[] testLocs = processConnection.FindInteger( -400, 4 );

                }
                //processConnection.Dispose();
            } catch ( Exception ) {
            } finally {
                
            }














            /*
            

            int pId;
            long memoryAddressRange;
            IntPtr baseAddress;

            Process[] processes = Process.GetProcessesByName( args[0] );
            if ( processes.Length > 0 ) {
                pId = Process.GetProcessesByName( args[0] ).FirstOrDefault().Id;
                memoryAddressRange = Process.GetProcessesByName( args[0] ).FirstOrDefault().PeakVirtualMemorySize64;
                baseAddress = Process.GetProcessesByName( args[0] ).FirstOrDefault().MainModule.BaseAddress;
            } else {
                Console.Out.WriteLine( "No process matches name specified" );
                return;
            }

            IntPtr pHandle = ProcessInterop.openProcessHandle( ProcessInterop.ProcessAccessFlags.All, true, pId );

            byte[] test = new byte[5000];
            int totalBytesRead;
            try {
                ProcessInterop.readProcessMemory( pHandle, baseAddress, ref test, out totalBytesRead );
            }catch(Exception){
            
            }finally{

                ProcessInterop.closeProcessHandle( pHandle );
            }*/
        }
    }
}
